/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projetweb.modeles;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author mankou
 */
@Entity
public class Commande implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private int datecreationcommande;
    private double totalcommande;
    private int etatcommande;
    @OneToOne
    private Client client;
    @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER,mappedBy="commande")
    private Collection<Lignecommande>lignecommande;

    public Commande() {
    }

    public Commande(int datecreationcommande, double totalcommande, int etatcommande) {
        this.datecreationcommande = datecreationcommande;
        this.totalcommande = totalcommande;
        this.etatcommande = etatcommande;
    }
    
    

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getDatecreationcommande() {
        return datecreationcommande;
    }

    public void setDatecreationcommande(int datecreationcommande) {
        this.datecreationcommande = datecreationcommande;
    }

    public int getEtatcommande() {
        return etatcommande;
    }

    public void setEtatcommande(int etatcommande) {
        this.etatcommande = etatcommande;
    }

    public double getTotalcommande() {
        return totalcommande;
    }

    public void setTotalcommande(double totalcommande) {
        this.totalcommande = totalcommande;
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public Collection<Lignecommande> getLignecommande() {
        return lignecommande;
    }

    public void setLignecommande(Collection<Lignecommande> lignecommande) {
        this.lignecommande = lignecommande;
    }
    
    
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) id;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Commande)) {
            return false;
        }
        Commande other = (Commande) object;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "projetweb.modeles.Commande[ id=" + id + " ]";
    }
    
}
